/* eslint-disable */
// 获取cookie、

export const cookieName = 'xxxxxx'

export function getAuthCookie() {
  return getCookie(cookieName)
}

export function setAuthCookie(val) {
  setCookie(cookieName, val, 7)
}

export function deleteAuthCookie() {
  delCookie(cookieName)
}

function getCookie (name) {
  var arr; var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
  if (arr = document.cookie.match(reg)) { return (arr[2]) } else { return null }
}

// 设置cookie,增加到vue实例方便全局调用
function setCookie (cname, cvalue, exdays) {
  console.log(cname)
  var d = new Date()
  d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
  var expires = 'expires=' + d.toUTCString()
  document.cookie = cname + '=' + cvalue + '; '+'path=/;' + expires
}

// 删除cookie
function delCookie (name) {
  setCookie(name, '', -1)
}
